

Operation on classic bits or cbits 
1)Identity f(x) = x   
2)Negation f(x) = -x
3) constant 0 f(x) =0
4)constant 1 f(x)=1

Reversible computing :
. Reversible means when an ouput value is given by the function , we can find the input value 
   . Identity and negation are reversible functions 
   . Constant 0 and Constant 1 are not reversible .

(image:https://tatourian.files.wordpress.com/2018/09/2.jpg)


Tensor of vectors :

(x0 \n x1) x (y0 \n y1) = (   x0(yo\n y1)   \n   x1(yo\n y1)  ) = (x0y0  \n  x0y1  \n x1y0  \n  x1y1 )


Representing multiple qbits :

|00> = (1 \n 0)x(1 \n 0) = ( 1  \n 0 \n 0 \n 0)

 similar for  |00> |01> |10> |11>

The product state for n qbits is 2^n

note : 0 is represented by (1 \n 0) and 1 is represented by (0 \n 1)

CNOT :

When the control control bit is 1 , the target bit is flipped , otherwise there is no change 

00 --> 00
01 --> 01
10 --> 11
11 --> 10

c = ( 1 0 0 0
      0 1 0 0
      0 0 0 1
      0 0 1 0)

c|10> = c ( 0  \n  1) x (1  \n  0) = ( 1 0 0 0    (0   \n  0  \n  1  \n  0 ) =(0  0  0  0) = ( 0  \n  1 ) x ( 0\n1)
                                       0 1 0 0
                                       0 0 0 1
                                       0 0 1 0)

= |11>

RECAP
1)operation on bits 
2) q computation uses only reversible operations
3) cnot is the fundamental gate in q computing and reversible computing

Qbits and superposition :
. cbit vectors are special cases of qbit vectors 
. a qbit represented by (a \n b) where a and b are complex numbers and ||a||^2 + ||b||^2 = 1 
.example qbit values (1/root2   \n   1/root2) (-1  \n  0)
it collapses to 0 with probability ||a||^2 and 1 with probability ||b||^2

The hadamard gate :

H|0> =  (1/root2  1/root2
           1/root2  -1/root2)  (1   \n  0) = (1/root2  \n  1/root2) [0 = 50% probability ; 1 = 50% probability ]

and if we multiply the result (1/root2  \n  1/root2)  with H, well get (1 / 0) again!
Note : the hadamard gate takes 0 and 1 bits to superposition and back

The unit circle state machine :

(https://tatourian.files.wordpress.com/2018/09/9.jpg)

x = bit flip, h = hadamard gate

(1 / 0) x h x h x (-1 / 0) , this is according to the table 

The Dutsch Oracle :(writng a non reversible function in a reversible way )
the black box problem
note :common hack: add an additional output qbut to which the function action is added . 

Before : input |x> ------------| b b |---------------------f(|x>)---output 

After :
output |x> ------------| b b |---------------------f(|x>)---output’
input |x>--------------|       |-------------------------|x>----input’

Constant zero (non reversible):
output |0> ------------| b b |---------------------|0>---output’
input |0>--------------|       |-------------------------|0>----input’

in here , inside the bb :
output------------------------
input--------------------------

Constant 1 (noon-reversible):

output |0> ------------| b b |---------------------|1>---output’
input |0>--------------|       |-------------------------|0>----input’

in here , inside the bb :
output--------------|x|----------
input--------------------------

Identity:


output |0> ------------| b b |---------------------|x>---output’
input |x>--------------|       |-------------------------|x>----input’

cnot gate 

output -----------O------------(target)
                           |
input--------------.-------------(control)

let input : 0 and output : 0

when input is 0 , the target output’ remains 0
when input is 1 , the target output’ changes to 1 

In negation the same thing will happen , but the result of output’ will get flipped because of |x| along the output :

output |0> ------------| b b |---------------------|-x>---output’
input |x>--------------|       |-------------------------|x>----input’

in bb :
output -----------O-----|x|-------(target)
                           |
input--------------.-------------(control)


a problem :

output |0> ----x---h-----| b b |----h-----------------|-x>---(meter)
input |0>-------x---h----|       |-----h--------------------|x>----(meter)

.if black box is constant , system will be in state |11> after measurement
.if black box is variable , system will be in state |01> after measurement
